home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Source / CASample / CAS_CTools.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  7.0 KB  |  297 lines  |  [TEXT/MPS ]

  1. /*
  2.  
  3.     File:        CAS_CTools.h
  4.  
  5.     Contains:    Globals and defines for all utility routines.
  6.  
  7.     Written by:    David H Nelson
  8.  
  9.     Copyright © 1988-1995 ComponentWorks, All rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <1>     2/14/95    SJF        first checked in
  14.          <1>     1988        DHN        Created.
  15. */
  16.  
  17. #if !defined(_H_CTools)
  18. #define _H_CTools
  19.  
  20. #undef GLOBAL
  21. #ifdef _CTOOLS_
  22. #define GLOBAL
  23. #else
  24. #define GLOBAL extern
  25. #endif
  26.  
  27. //--------------------------------------------------------------------------
  28.  
  29. #if !defined(__MIXEDMODE__)
  30. // These are from the universal headers
  31. typedef ProcPtr UniversalProcPtr, *UniversalProcHandle;    // from Types.h
  32. typedef UniversalProcPtr DeviceLoopDrawingUPP;            // from QuickDraw.h
  33. typedef UniversalProcPtr DlgHookYDUPP;                    // from StandardFile.h
  34. typedef UniversalProcPtr ModalFilterUPP;                // from Dialogs.h
  35. typedef UniversalProcPtr ModalFilterYDUPP;                // from StandardFile.h
  36. typedef UniversalProcPtr ControlActionUPP;                // from Controls.h
  37. typedef UniversalProcPtr AEEventHandlerUPP;                // from AppleEvents.h
  38. typedef UniversalProcPtr ColorSearchUPP;                // from ???.h
  39. #endif
  40.  
  41. #if !defined(__LOWMEM__)
  42. #define LMGetDoubleTime() (* (long *) 0x02F0)            // from LowMem.h
  43. #endif
  44.  
  45. //--------------------------------------------------------------------------
  46.  
  47. #define CToolsBaseID        16000
  48.  
  49. #define aboutTYPE            'ABOT'
  50. #define aboutICON            CToolsBaseID
  51.  
  52. #define CStringsID            CToolsBaseID
  53. #define sizeStrings            CStringsID+1
  54. enum {
  55.     inByteSize = 1,
  56.     inKBSize,
  57.     inMBSize
  58. };
  59.  
  60. //#define _68000_     /* use 68000 asm where possible */
  61. #define arrowCursor        0
  62.  
  63. #define INFRONT            ((WindowPtr) -1L)
  64.  
  65. #define kInitWindowHOffset    8
  66. #define kInitWindowVOffset    (GetMBarHeight() + 4)
  67.  
  68. #define ScrapSize        (0x960)
  69. #define BootDrive        (0x210)
  70. #define CurrentA5        (0x904)
  71. #define GrayRgn            (0x9EE)
  72. #define MainDevice        (0x8A4)
  73. #define WMgrPort        (0x9DE)
  74. #define ROM85            (0x28E)
  75. #define MBarHeight        (0xBAA)
  76.  
  77. #define LoMemScrapStuff    ((Ptr) ScrapSize)                /* scrap record in lo-mem */
  78. #define LoMemBootDrive    (* (short*) BootDrive)            /* working directory of system folder */
  79. #define LoMemA5            (* (long*) CurrentA5)            /* current A5 */
  80. #define LoMemGrayRgn    (* (RgnHandle*) GrayRgn)        /* gray region */
  81. #define LoMemMainDevice    (* (GDHandle*) MainDevice)        /* main device */
  82. #define    LoMemWMgrPort    (* (GrafPtr*) WMgrPort)            /* WMgrPort */
  83. #define    LoMemROM85        (* (unsigned short*) ROM85)        /* ROM version */
  84. #define    HaveCQD()        (LoMemROM85 <= 0x3FFF)            /* true if color quickdraw is present */
  85. #define    LoMemMBarHeight    (* (short*) MBarHeight)            /* MBarHeight */
  86.  
  87. /* Key codes for handling keys */
  88.  
  89. #define kHome            0x01
  90. #define kEnter            0x03
  91. #define kEnd            0x04
  92. #define kDelete            0x08
  93. #define kPageUp            0x0B
  94. #define kPageDown        0x0C
  95. #define    kFunctionKeys    0x10
  96. #define kEscape            0x1B    
  97. #define kLeftArrow        0x1C
  98. #define kRightArrow        0x1D
  99. #define kUpArrow        0x1E
  100. #define kDownArrow        0x1F
  101.  
  102. #define topLeft(r)        (((Point *) &(r))[0])
  103. #define botRight(r)        (((Point *) &(r))[1])
  104.  
  105. // macros to check file and directory attributes.
  106. #define ISDIRECTORY(pb)    ((pb.dirInfo.ioFlAttrib & ioDirMask) != 0)
  107. #define ISFILE(pb)         ((pb.dirInfo.ioFlAttrib & ioDirMask) == 0)
  108. #define ISLOCKED(pb)     ((pb.hFileInfo.ioFlAttrib & 0x01) != 0)
  109. #define ISBUSY(pb)         ((pb.hFileInfo.ioFlAttrib & 0x80) != 0)
  110.  
  111. /* WARNING! min, max, and abs evaluate their parameters more than once! */
  112. /* Be careful about using function calls or expressions with side-effects. */
  113. #define min(a,b)    ((a) < (b) ? (a) : (b))
  114. #define max(a,b)    ((a) > (b) ? (a) : (b))
  115. #define abs(a)        ((a) >  0  ? (a) : -(a))
  116.  
  117. #define appendChar(src,dst)    (dst)[++(dst)[0]] = (src)
  118. #define userCancelErr            userCanceledErr /* was 1, then 32767, now -128, same as userCanceledErr*/
  119. #define mountITEM                -128
  120.  
  121. #define KB *(long)1<<10    /* convenient abbreviations for kilobytes and megabytes */
  122. #define    MB *(long)1<<20
  123.  
  124. #define MAXINQSIZE    36
  125. #define MAXREQSIZE    35
  126. #define MAXAUXSIZE    9
  127.  
  128. /* ulong is particularly important when working with the current time in seconds… */
  129. /* which at this point in history is a negative # */
  130. #define ulong    unsigned long
  131. #define uint    unsigned short
  132.  
  133. #define ushort    unsigned short
  134.  
  135. #define noDeviceID    (-1)
  136.  
  137. #define HVCB VCB
  138. #define HDrvQEl DrvQEl
  139. #define HDrvQElPtr DrvQElPtr
  140.  
  141. enum {
  142.     aboutDLOG=CToolsBaseID,volumeDLOG,informDLOG,verifyDLOG,saveScriptDLOG,
  143.     confirmDLOG,yesNoCancelDLOG,progressDLOG,errorDLOG,getSCSIDLOG,passwordDLOG,
  144.     getdriveDLOG,messageDLOG,helpDLOG,getDateDLOG
  145. };
  146.  
  147. enum {
  148.     errRetry=1,errContinue,errAbort
  149. };
  150.  
  151. enum {
  152.     confirmCancel=0,confirmOK
  153. };
  154.  
  155. #if 0
  156. typedef unsigned char Str63[64];
  157. #endif
  158.  
  159. typedef enum {
  160.     noSCSISErr,getSErr,selectSErr,cmdSErr,readSErr,writeSErr,completeSErr
  161. }
  162. SCSIError;
  163.  
  164. typedef enum {
  165.     goodStatErr=0,checkSenseStatErr=2,busyStatErr=8
  166. }
  167. SCSIStatError;
  168.  
  169. typedef enum {
  170.     noTransfer,readTransfer,writeTransfer
  171. }
  172. transferType;
  173.  
  174. typedef struct {
  175.     long            liTimeOut;
  176.     transferType     ttTransfer;
  177.     short            iPramLen;
  178.     char            cPramBlk[12];
  179. }
  180. SCSICmdBlk;
  181.  
  182. typedef struct {
  183.     long            vendor[2];
  184.     long            model[4];
  185.     short            iMin;
  186.     short            iMax;
  187.     short            iInterleave[3];    /* interleave for Mac II, SE, Plus */
  188. }
  189. deviceDef;
  190.  
  191. typedef struct {
  192.     short            drSigWord;
  193.     long            drCrDate;
  194.     long            drLsMod;
  195.     short            drAtrb;
  196.     short            drNmFls;
  197.     short            drVBMSt;
  198.     short            drAllocPtr;
  199.     short            drNmAlBlks;
  200.     long            drAlBlkSiz;
  201.     long            drClpSIz;
  202.     short            drAlBlSt;
  203.     long            drNxtCNID;
  204.     short            drFreeBks;
  205.     char            drVN[28];
  206.     long            drVolBkUp;
  207.     short            drVSeqNum;
  208.     long            drWrCnt;
  209.     long            drXTClpSiz;
  210.     long            drCTClpSiz;
  211.     short            drNmRtDirs;
  212.     long            drFilCnt;
  213.     long            drDirCnt;
  214.     long            drFndrInfo[8];
  215.     short            drVCSize;
  216.     short            drVBMCSiz;
  217.     short            drCtlCSiz;
  218.     short            drXTFlSize;
  219.     long            drXTExtRec[3];
  220.     short            drCTFlSize;
  221.     long            drCTExtRec[3];
  222. }
  223. VIB, *pVIB, **hVIB;
  224.  
  225. #define pdSigWord    0x5453        /* old partition map signature */
  226.  
  227. typedef struct
  228. {
  229.     long pdStart;
  230.     long pdSize;
  231.     long pdFSID;
  232. }
  233. oldPartRec;
  234.  
  235. typedef struct
  236. {
  237.     short        pdSig;
  238.     oldPartRec    partitions[];
  239. }
  240. oldPartMapRec, **hOldPartMap;
  241.  
  242. typedef struct
  243. {
  244.     short        txFont;
  245.     Style        txFace;
  246.     short        txMode;
  247.     short        txSize;
  248. }
  249. FontState;
  250.  
  251. // extern short MBarHeight    : 0xBAA;
  252.  
  253. //--------------------------------------------------------------------------
  254. // global variables - These are the theDoc for the utility routines. Some 
  255. // of them may not be used.
  256. GLOBAL short        firstGlobal;
  257. GLOBAL Boolean        bDirtyMenus;
  258. GLOBAL ulong        ulCTimeWaiting;
  259. GLOBAL ulong        ulCTimeWaitingTemp;
  260. GLOBAL StringPtr    sButtonHook;
  261. GLOBAL short        iApplResFile;
  262. GLOBAL short        iToolResFile;
  263. GLOBAL WindowPtr    wpClipboard;
  264. GLOBAL DialogPtr    dpMessage;
  265. GLOBAL DialogPtr    dpProgress;
  266. GLOBAL PatPtr        ppCurrent;
  267. GLOBAL Boolean        runningSystem7;
  268. GLOBAL Boolean        hasColorQD;
  269. GLOBAL Boolean        has32BitQD;
  270. GLOBAL Boolean        hasDragMgr;
  271. GLOBAL Boolean        hasTEGetHiliteRgn;
  272. GLOBAL Boolean        filler1;
  273. GLOBAL short        iOKITEM,iCancelITEM;
  274. GLOBAL short        SCSIStatus,SCSIMessage;
  275. GLOBAL SCSIError    theSCSIError;
  276. GLOBAL long            lGenericDialogMessage;
  277. GLOBAL char            cReqData[256 /* MAXREQSIZE*/];
  278. GLOBAL Str255        resStr;
  279. GLOBAL short        lastGlobal;
  280.  
  281.  
  282. //--------------------------------------------------------------------------
  283.  
  284. #if defined(__cplusplus)
  285. extern "C"
  286. {
  287. #endif
  288.  
  289. void InitTools(void);
  290.  
  291. #if defined(__cplusplus)
  292. }
  293. #endif
  294.  
  295.  
  296. #endif
  297.